#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
bool isnum_a(char a)  //判断是否合理
{
	if ((a >= 'A' && a <= 'z'))
		return true;
	else
		return false;
}
void count(fstream& outfile, int* b)
{
	char a[256];
	while (outfile.getline(a, 256))
	{
		int tmp = 0;
		for (int i = 0; i < strlen(a); i++)
		{
			if (isnum_a(a[i]))//统计字符数
			{
				b[1]++;   tmp++;
			}
			if (a[i] == ' ' || a[i] == '.' || a[i] == ',' || a[i] == '?' || a[i] == '!')//统计单词数
				b[0]++;
			if (a[i] == '.' || a[i] == '?' || a[i] == '!')
				b[2]++;  //统计句子数  
		}
	}
	outfile.close();
	return;
}
int main()
{
	while (1)
	{
		char filename[256];
		int b[3] = { 0 };
		char mod;
		cout << "wc.exe -";//输入统计的文本的路径
		cin >> mod;
		cin.getline(filename, 256);
		fstream outfile(filename, ios::in);
		count(outfile, b);
		if (mod == 'c')
			cout << "文本中的字符数: " << b[0] << endl;
		if (mod == 'w')
			cout << "文本中的单词数:" << b[1] << endl;
		if (mod == 's')
			cout << "文本中的句子数:" << b[2] << endl;
	}

	system("pause");
	return 0;
}